﻿using System;

namespace SBPweb.Communication.Shared.Library.Commands
{

    public abstract class CommandBase : ICommand
    {

        #region Methods

        public abstract object GetRequest();

        public abstract void PutResponse(object response);

        public abstract Type GetRequestType();

        public abstract Type GetResponseType();

        #endregion

    }

    public abstract class CommandBase<TRequest, TResponse> : CommandBase, ICommand<TRequest, TResponse>
    {

        #region Methods

        public override object GetRequest()
        {
            return GetTypedRequest();
        }

        public abstract TRequest GetTypedRequest();

        public override void PutResponse(object response)
        {
            PutTypedResponse((TResponse)response);
        }

        public abstract void PutTypedResponse(TResponse response);

        public override Type GetRequestType()
        {
            return typeof(TRequest);
        }

        public override Type GetResponseType()
        {
            return typeof(TResponse);
        }

        #endregion

    }

}